/*
 * Copyright 2016 Crown Copyright
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package stroom.core.db.migration._V07_00_00.doc.statistics.sql;

import stroom.core.db.migration._V07_00_00.docref._V07_00_00_HasDisplayValue;
import stroom.core.db.migration._V07_00_00.docref._V07_00_00_SharedObject;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "statisticField", propOrder = {"fieldName"})
public class _V07_00_00_StatisticField
        implements _V07_00_00_HasDisplayValue, Comparable<_V07_00_00_StatisticField>, _V07_00_00_SharedObject {
    private static final long serialVersionUID = 8967939276508418808L;

    @XmlElement(name = "fieldName")
    private String fieldName;

    public _V07_00_00_StatisticField() {
        // Default constructor necessary for GWT serialisation.
    }

    public _V07_00_00_StatisticField(final String fieldName) {
        this.fieldName = fieldName;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(final String fieldName) {
        this.fieldName = fieldName;
    }

    @Override
    public int compareTo(final _V07_00_00_StatisticField o) {
        return fieldName.compareToIgnoreCase(o.fieldName);
    }

    @Override
    public String getDisplayValue() {
        return null;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((fieldName == null) ? 0 : fieldName.hashCode());
        return result;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        final _V07_00_00_StatisticField other = (_V07_00_00_StatisticField) obj;
        if (fieldName == null) {
            if (other.fieldName != null)
                return false;
        } else if (!fieldName.equals(other.fieldName))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "StatisticField [fieldName=" + fieldName + "]";
    }

    public _V07_00_00_StatisticField deepCopy() {
        return new _V07_00_00_StatisticField(new String(fieldName));
    }

}
